<template>
	<view class="b_width hui">
		<view class="status_box b_f_w">{{info.statusText}}</view>
		<view class="b_flex_c box">
			<view class="">
				<text class="iconfont iconshouhuodizhi fs-24 gray_font"></text>
			</view>
			<view>
				<view class="b_flex_c">
					<view>{{info.sh_name}}</view>
					<view class="mobile">{{info.sh_mobile}}</view>
				</view>
				<view class="site">{{info.site}}</view>
			</view>
		</view>



		<view class="box">
			<view class="title">定制信息</view>
			<view class="m_b">
				<view class="b_flex">
					<image mode="widthFix" class="img" :src="info.images"></image>
					<view class="ginfo">
						<view class="name">{{info.name}}</view>
					    <view class="num">x {{info.num}} 人</view>
					
					</view>
				</view>
			</view>
		</view>

		<view class="box">
			<view class="title">金额信息</view>
			<view class="b_flex_c_s info">
				<view>订单总价</view>
				<view>￥{{info.money}}</view>
			</view>
			<view class="b_flex_c_s info">
				<view>实付款</view>
				<view class="b_red">￥{{info.pay}}</view>
			</view>
		</view>

		<view class="box">
			<view class="title">支付信息</view>
			<view class="b_flex_c_s info">
				<view>订单编号</view>
				<view>{{info.order_no}}</view>
			</view>
			<view class="b_flex_c_s info">
				<view>下单时间</view>
				<view>{{info.createtime}}</view>
			</view>
			<view class="b_flex_c_s info">
				<view>预约时间</view>
				<view>{{info.yc_time}}</view>
			</view>
			<view class="b_flex_c_s info">
				<view>支付方式</view>
				<view>{{info.payType}}</view>
			</view>
			<view class="b_flex_c_s info">
				<view>支付状态</view>
				<view>{{info.payStatus}}</view>
			</view>
		</view>

      <view style="height: 180rpx;" v-if="info.status==1"></view>
     <view class="bottom" v-if="info.status==1">
     	<view class="btn btn_red" v-if="info.status==1" @click="pay()">立即支付</view>
     	<view class="btn " v-if="info.status==1" @click="cancel()">取消订单</view>
		
		<view class="btn " v-if="item.status==3" @click="quess(item,index)">完成订单</view>
     </view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:'',
				info: {}
			}
		},
		onLoad(e) {
			if (e.id) {
				this.id=e.id
				this.getInfo();
			}
		},
		methods: {
			quess(e,index){
				let _=this;
				uni.showModal({
					title:'温馨提示',
					content:'确认订单完成?',
					success: (res) => {
						if(res.confirm){
							_.$post(_.$api.porderQue,{id:e.id,type:2,token:uni.getStorageSync('userToken')},ress=>{
								let {code,data,msg}=ress.data;
								if(code==1){
									_.$project.toast(msg);
								   _.getInfo();
									
								}
							});
							
						}
					}
				})
			},
			cancel(e,index){
				let _=this;
				uni.showModal({
					title:'温馨提示',
					content:'是否取消订单?',
					success: (res) => {
						if(res.confirm){
							
							_.$post(_.$api.pcancel,{id:_.info.id,token:uni.getStorageSync('userToken')},ress=>{
								let {code,data,msg}=ress.data;
								if(code==1){
									_.$project.toast(msg);
								    _.getInfo();
									
								}
							});
							
						}
					}
				})
			},
			pay(e,index){
				let _=this;
				this.$post(this.$api.ppay,{id:this.info.id,token:uni.getStorageSync('userToken')},ress=>{
					let {code,data}=ress.data;
					if(code!=1) return;
					
					uni.requestPayment({
						provider: 'wxpay',
						timeStamp: data.timeStamp,
						nonceStr: data.nonceStr,
						package: data.package,
						signType: data.signType,
						paySign: data.paySign,
						success: function(res) {
							_.$Toast('支付成功');
						   _.getInfo();
						},
						fail: function(err) {
							_.$Toast('支付取消');
						}
					});
				});
			},
			
			getInfo(id) {
				this.$get(this.$api.pinfo, {
					id: this.id
				}, res => {
					let {
						code,
						data
					} = res.data;
					if (code == 1) {
						this.info = data;
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.b_flex_c {
		display: flex;
		align-items: center;
	}

	.b_flex {
		display: flex;
	}

	.b_flex_c_s {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.status_box {
		background-color: #FF7133;
		color: white;
		box-sizing: border-box;
		padding: 30rpx 30rpx;
		margin-bottom: 30rpx;
	}

	.sh_img {
		width: 50rpx;
		margin-right: 20rpx;
	}

	.box {
		box-sizing: border-box;
		padding: 30rpx 30rpx;
		background-color: white;
		margin-bottom: 30rpx;
	}

	.mobile {
		color: #8E8E8E;
		font-size: 26rpx;
		margin-left: 10rpx;
	}

	.site {
		font-size: 26rpx;
		margin-top: 5rpx;
	}

	.title {
		box-sizing: border-box;
		padding: 0 0 30rpx 0;
		border-bottom: 1rpx solid #eee;
		font-weight: bold;
	}


	.img {
		width: 35%;
		border-radius: 25rpx;
	}

	.ginfo {
		margin-left: 5%;
		width: 60%;
	}

	.m_b {
		margin-top: 30rpx;
	}

	.num {
		color: #999;
		font-size: 24rpx;
		margin-top: 20rpx;
		text-align: right;
	}

	.info {
		box-sizing: border-box;
		padding: 20rpx 0 0 0;
	}
	
	.bottom{
		position: fixed;
		left:0;
		bottom: 0;
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		box-sizing: border-box;
		padding: 45rpx 30rpx 45rpx 30rpx;
		background-color: white;
	}
	.btn{
		box-sizing: border-box;
		padding: 20rpx 50rpx;
		border: 1rpx solid black;
		font-size: 26rpx;
		border-radius: 45rpx;
		margin-left: 20rpx;
	}
	.btn_red{
			border: 1rpx solid red;
			color:red;
	}
</style>